home *** CD-ROM | disk | FTP | other *** search
- This directory contains source code for the sml interpreter.
-
- A few tips on extending the interpreter:
-
- To add new primitive operators:
-
- -- Write a C procedure that returns an int and accepts no parameters.
- The return value should be TRUE if no errors were encountered, FALSE
- otherwise (someday the return codes can be used to do error recovery,
- etc.). The procedure receives its operands from the operand stack,
- generally by calling Pop(). See ``stdops.c'' for lots of examples of
- primitive operators.
-
- -- In the file optable.h, list the new procedure as extern, then add an
- entry for it in the PrimitiveTable.
-
-
- To add a new primitive data type:
-
- -- Add a new entry to ``enum TokenType'' located in machine.h. New entries
- must be placed just before the NumTokens symbol.
-
- -- Add any necessary data fields to the type ``Token'' (also located in
- machine.h).
-
- -- Write procedures that evaluate, execute, print, free and make copies
- of tokens of the new type. (Evaluation and execution currently
- differ only in the treatment of CodeBody(s), so you probably only
- have to write a single procedure to perform both of these
- operations.)
-
- -- In methods.h, declare the new procedures external, then enter their
- names in the ``Methods'' table. The ordering of the rows of the Methods
- table must match the ordering of the symbols in ``enum TokenType.''
-
- -- If the token that you're adding can be stated literally on the input
- stream, then you'll also have to change the scanner and parser (located
- in scanner.l, parser.h, and parser.c).
-
-